package LuoGu.搜索.烤鸡;

import java.util.Scanner;

public class Main {
    static int [][] ans = new int [10000][10];
    static int [] temp = new int [10];
    static int index = 0;
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        kao(0,0,n);
        System.out.println(index);
        for(int i=0;i<index;i++){
            for(int j=0;j<10;j++){
                System.out.print(ans[i][j]+" ");
            }
            System.out.println();
        }
    }

    public static void kao(int a, int all, int n){
        if(a==10){
            if(all==n){
                for(int i=0;i<10;i++){
                    ans[index][i] = temp[i];
                }
                index++;
            }
        }
        else if(all>n) ;
        else if(a<10){
            for(int i=1;i<=3;i++){
                temp[a] = i;
                kao(a+1,all+temp[a],n);
            }
        }
    }
}
